Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docker] Fix runtime check_is_active sysroot consideration #3375

Merged

Conversation

TurboTurtle
Copy link
Member

A runtime's check_is_active() does not get passed a sysroot at any point, so the docker runtime abstraction should just use the policy sysroot directly.

Additionally, check_can_copy() should be simplified to simply return the already-determined active state of the runtime.


Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines

  • Is the commit message split over multiple lines and hard-wrapped at 72 characters?
  • Is the subject and message clear and concise?
  • Does the subject start with [plugin_name] if submitting a plugin patch or a [section_name] if part of the core sosreport code?
  • Does the commit contain a Signed-off-by: First Lastname [email protected]?
  • Are any related Issues or existing PRs properly referenced via a Closes (Issue) or Resolved (PR) line?

A runtime's `check_is_active()` does not get passed a sysroot at any
point, so the docker runtime abstraction should just use the policy
sysroot directly.

Additionally, `check_can_copy()` should be simplified to simply return
the already-determined active state of the runtime.

Signed-off-by: Jake Hunsaker <[email protected]>
@packit-as-a-service
Copy link

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/sosreport-sos-3375
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

(self.policy.init_system.is_running('docker') or
self.policy.init_system.is_running('snap.docker.dockerd'))):
self.active = True
return True
return False

def check_can_copy(self):
return self.check_is_active(sysroot=self.policy.sysroot)
return self.active
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.active = False until check_is_active is called (applies both for ContainerRuntime and DockerContainerRuntime). Can't we get wrong False return here just because we haven't called check_is_active?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current flow, no, because a runtime is only loaded if check_is_active() returns True when the policy is loaded. If this call returns False during policy instantiation, we drop the runtime entirely.

If someone were to separately try to leverage a runtime here, theoretically yes they could end up calling this before check_is_acitve(), but that's not something we support.

@TurboTurtle TurboTurtle merged commit 229cf23 into sosreport:main Oct 10, 2023
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants